<div th:fragment="buttonHTML">
	<div class="layui-inline header-btn" style="margin-left: 10px;">
		<button type="button" th:if="${dto.headerButton.save == 1}" class="layui-btn layui-btn-normal" lay-submit lay-filter="formSubmit"><i class="iconfont icon-save"></i>保存</button>
		<button type="button" th:if="${dto.headerButton.pass == 1}" class="layui-btn" id="id_btn_flow_pass"><i class="iconfont icon-right-btn"></i>流转</button>
		<button type="button" th:if="${dto.headerButton.refuse == 1}" class="layui-btn layui-btn-warm" id="id_btn_flow_refuse"><i class="iconfont icon-left-btn"></i>驳回</button>
		<button type="button" th:if="${dto.headerButton.flowLog == 1}" class="layui-btn layui-btn-primary" id="id_btn_flow_log"><i class="iconfont icon-time-history"></i>流程跟踪</button>
		<button type="button" th:if="${dto.headerButton.delete == 1}" class="layui-btn layui-btn-danger" id="id_btn_delete_true"><i class="iconfont icon-delete"></i>删除</button>
	</div>
</div>
<div th:fragment="buttonJS">
	<script type="text/javascript">
	$(function () {
        $('#id_btn_flow_pass').on('click',function (e) {

			var indexOfLoading = layer.load(1, {
				shade: [0.5,'#000000'] //0.1透明度的白色背景
			});
			
			layer.confirm('确定流转？ ', {
					btn: ['确定','取消'] //按钮
				}, function(){
					$.ajax({
						type: "POST",
						url: '[(${dto.pathFlowPass})]',
						data: {},
						success: function (data) {
							if (data.code == 0) {
								layer.msg(data.msg);
								setTimeout(function(){
									location.reload();
								}, 1000);
							} else {
								alert(data.msg);
							}
						}
					});
				}, function(){layer.close(indexOfLoading);}
			);
        });
		
        $('#id_btn_flow_refuse').on('click',function (e) {

			var indexOfLoading = layer.load(1, {
				shade: [0.5,'#000000'] //0.1透明度的白色背景
			});
			
			layer.confirm('确定驳回？ ', {
					btn: ['确定','取消'] //按钮
				}, function(){
					$.ajax({
						type: "POST",
						url: '[(${dto.pathFlowRefuse})]',
						data: {},
						success: function (data) {
							if (data.code == 0) {
								layer.msg(data.msg);
								setTimeout(function(){
									location.reload();
								}, 1000);
							} else {
								alert(data.msg);
							}
						}
					});
				}, function(){layer.close(indexOfLoading);}
			);
        });
		
        $('#id_btn_flow_log').on('click',function (e) {
        	var w=($(window).width()*0.9);
        	var h=($(window).height() - 50);
            layer.open({
                type: 2,
                area: [w+'px', h +'px'],
                fix: true,
                maxmin: false,
                shadeClose: true,
                shade:0.4,
                title: "流程跟踪",
                content: '/web/flow/ysp/toAudit?bid=[[${dto.bid}]]'
            });
        });
		
        $('#id_btn_delete_true').on('click',function (e) {

			var indexOfLoading = layer.load(1, {
				shade: [0.5,'#000000'] //0.1透明度的白色背景
			});
			
			layer.confirm('确定删除？ ', {
					btn: ['确定','取消'] //按钮
				}, function(){
					$.ajax({
						type: "POST",
						url: '[(${dto.pathCommitDelete})]',
						data: {},
						success: function (res) {
							if (res.code == 0) {
								layer.msg(res.msg);
								layer.close(indexOfLoading);
								setTimeout(function(){
									parent.layer.close(parent.layer.getFrameIndex(window.name));
								}, 1000);
							} else {
								layer.close(indexOfLoading);
								layer.msg(res.msg);
							}
						}
					});
				}, function(){layer.close(indexOfLoading);}
			);
        });
	});
	</script>
</div>